import {Component, OnInit} from '@angular/core';
import {Auth} from '../../_models/auth';
import {AuthService} from '../../_services/auth.service';
import {HttpErrorResponse} from '@angular/common/http';

@Component({
  selector: 'app-reset',
  templateUrl: './reset.component.html',
  styleUrls: ['./reset.component.css'],
})
export class ResetComponent implements OnInit {
  auth: Auth;

  constructor(private authService: AuthService) {
    this.auth = new Auth();
  }

  ngOnInit() {
  }

  reset(): void {
    console.log(this.auth);
    this.authService.doReset(this.auth).subscribe(
      data => {
        console.log(data.toString());
        this.authService.jwtToken = data.toString();
      },
      (err: HttpErrorResponse) => {
        console.log(err.error);
      }
    );
  }
}
